//
//  MEController.h
//  MapEditor
//
//  Created by Eric on 3/3/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "MEPrototypeTabView.h"
#import "MEPrototype.h"
#import "MEEditStageLayer.h"
#import "MEGLView.h"

@interface MEController : NSWindowController{
    NSString* dataFilePath;
    
    MEGLView* glView;
    
    MEPrototypeTabView* prototypeTabView;
    NSPopUpButton *prototypeTabPopBtn;
    
    //box2d template
    IBOutlet NSTextField* prototypeClassField;
    IBOutlet NSMatrix* prototypeFileTypeField;
    IBOutlet NSButton *prototypeBox2dField;
    IBOutlet NSTextField *prototypeDField;
    IBOutlet NSTextField *prototypeFField;
    IBOutlet NSTextField *prototypeRField;
    IBOutlet NSMatrix* prototypeTField;
    IBOutlet NSMatrix* prototypeSField;
    IBOutlet NSButton* prototypeEditShapeBtn;
    IBOutlet NSButton* prototypeSoftBodyBtn;
    IBOutlet NSTextField *prototypeSoftNField;
    IBOutlet NSTextField *prototypeSoftHzOutField;
    IBOutlet NSTextField *prototypeSoftDpOutField;
    IBOutlet NSTextField *prototypeSoftHzInField;
    IBOutlet NSTextField *prototypeSoftDpInField;
    IBOutlet NSTextField *prototypeSoftInnerRateXField;
    IBOutlet NSTextField *prototypeSoftInnerRateYField;
    
    
    //sprite
    IBOutlet NSTextField* sptIDField;
    IBOutlet NSTextField* sptClassField;
    IBOutlet NSTextField* sptFileTypeField;
    
    IBOutlet NSTextField* sptXField;
    IBOutlet NSTextField* sptYField;
    IBOutlet NSButton* sptFlipXField;
    IBOutlet NSButton* sptFlipYField;
    
    IBOutlet NSTextField* sptRField;
    IBOutlet NSSlider* sptRSlider;
    IBOutlet NSTextField* sptSCField;    
    IBOutlet NSSlider* sptSCSlider;
    IBOutlet NSButton *sptBox2dField;
    IBOutlet NSTextField *sptBodyDField;
    IBOutlet NSTextField *sptBodyFField;
    IBOutlet NSTextField *sptBodyRField;
    IBOutlet NSMatrix* sptBodyTField;
    IBOutlet NSMatrix* sptBodySField;
    IBOutlet NSButton* sptSoftBtn;
    IBOutlet NSTextField *sptSoftNField;
    IBOutlet NSTextField *sptSoftHzOutField;
    IBOutlet NSTextField *sptSoftDpOutField;
    IBOutlet NSTextField *sptSoftHzInField;
    IBOutlet NSTextField *sptSoftDpInField;
    IBOutlet NSTextField *sptSoftInnerRateXField;
    IBOutlet NSTextField *sptSoftInnerRateYField;
    
    IBOutlet NSTextField* sptTag0Field;
    IBOutlet NSTextField* sptTag1Field;
    IBOutlet NSTextField* sptTag2Field;
    IBOutlet NSTextField* sptTag3Field;
    
    //screen
    IBOutlet NSTextField* glWField;
    IBOutlet NSTextField* glHField;
    IBOutlet NSSlider* glSlider;
    IBOutlet NSTextField* glSField;
    IBOutlet NSMatrix* glRotationField;
    
    NSCollectionView* layersPane;
    
    //stage
    NSTabView* stageTabView;
    NSPopUpButton *stageTabPopBtn;
    
    NSButton* testBuildBtn;
    NSButton* testStopBtn;
    NSButton* testRestBtn;
        
    //debug
    IBOutlet NSButton* debugShapeField;
    IBOutlet NSButton* debugJointField;
    IBOutlet NSButton* debugAABBField;
    IBOutlet NSButton* debugPairField;
    IBOutlet NSButton* debugMassCenterField;
    IBOutlet NSButton* worldEdgeField;
    
    NSButton* drawEdgeField;
    //NSCollectionView* mapCollectionView;
}
@property(nonatomic, retain)NSString* dataFilePath;
@property(nonatomic, retain)IBOutlet MEGLView* glView;
@property(nonatomic, retain)IBOutlet MEPrototypeTabView* prototypeTabView;
@property(nonatomic, retain)IBOutlet NSPopUpButton *prototypeTabPopBtn;

@property(nonatomic, retain)IBOutlet NSCollectionView* layersPane;

@property(nonatomic, retain)IBOutlet NSTabView* stageTabView;
@property(nonatomic, retain)IBOutlet NSPopUpButton *stageTabPopBtn;

@property(nonatomic, retain)IBOutlet NSButton *testBuildBtn;
@property(nonatomic, retain)IBOutlet NSButton *testStopBtn;
@property(nonatomic, retain)IBOutlet NSButton *testRestBtn;

@property(nonatomic, retain)IBOutlet NSButton* drawEdgeField;

//@property(nonatomic, retain)IBOutlet NSCollectionView* mapCollectionView;

+(MEController*)instance;
-(void)refreshPrototypeInfo;
-(MEPrototype*)selectedPrototype;
-(void)refreshSpriteInfo:(MEEditStageSprite*)spt;
-(void)refreshDebugInfo:(MEBox2dLayer*)layer;

-(MEEditStageSubLayer*)selectedLayer;
-(IBAction)addStage:(id)sender;
-(void)openFile:(NSURL*)url;
@end
